/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*	
*	Julio Montes e-mail: imc.coder@gmail.com 
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#ifndef SDK_EDITOR_H
#define SDK_EDITOR_H

#include "sdk/include/filecfg.h"

#include <wx/wxscintilla.h>


namespace sdk
{
    class Lexer;

    class Editor : public wxScintilla
    {
    public:
        static const wxString s_fileConfig;

        static const wxString FontEncodingString[];

        Editor( wxWindow *parent, wxWindowID id );

        virtual ~Editor();

        bool CanCopy() const;

        bool CanCut() const;

        //bool CanPaste() const;

//        bool CanAutoComplete() const;

        void SetSelection( long posStart, long posEnd );

        void StripTrailingSpaces();

        void SetLexer( const sdk::Lexer *lexer );

        void LoadFile( const wxString &fileName );

		void SetFileName( const wxString &filename );

        const wxString &GetFileName() const;

        const wxString &GetFontEncoding() const;

        void LoadSettings();

        void Autocomplete( bool key=false );
    protected:
    private:
        void OnUpdateUI( wxScintillaEvent &evt );

        void OnCharAddeed( wxScintillaEvent &evt );

        void OnMarginClick( wxScintillaEvent &evt );

        void OnKillFocus( wxFocusEvent &evt );

        void LoadGeneralSettings();
        void LoadOtherSettings();
        void LoadAutoCompleteSettings();
        void LoadFoldSettings();

        void HighlightOccurrences();
        void HighlightBrace();
        void AutoCompleteBrace( wxChar c );

        bool m_autoComplete;
        int m_numberLetters;
        wxString m_fontEncoding;
        wxString m_filename;

        const sdk::Lexer *m_lexer;

        sdk::FileConfig *m_fileConfig;

        DECLARE_EVENT_TABLE()
    };
}

#endif // SDK_EDITOR_H
